﻿@model sBlog.Net.Areas.Admin.Models.AdminUploadsViewModel

@{
    ViewBag.Title = string.Format("Manage Uploads || {0}", Model.Title);
}

<div id="left" style="float: left; width: 20%; padding: 5px;"> 

</div>
<div style="float: right">
    <a href="#upload-new">upload a file</a>
</div>
<div id="right" style="float: left; width: 60%">
    <table id="manage-table">
        <thead>
            <tr>
                <th class="header" scope="col">File Name</th>
                <th class="header" scope="col">Manage</th>
            </tr>
        </thead>
        <tbody>            
            @if (Model.FileEntries.Count == 0)
            {
                <tr>
                    <td>
                        there are no items in this section at this point!
                    </td>
                    <td></td>
                </tr>
            }

            @foreach (var item in Model.FileEntries)
            {
                var imgUrl = Url.Content("~/Content/Images/extension_icons/" + item.FileIconName);
                <tr>
                    <td>
                        <span>
                            <a href="@item.FileUrl" class="upload-item">
                                <img src="@imgUrl" alt="@item.FileName" class="upload-img" />
                                <span>@item.FileName</span>
                            </a>
                        </span>
                    </td>
                    <td>
                        <img class="deleteFile" data-file-name="@item.FileName" src="@Url.Content("~/Content/Images/close_delete.png")" alt="" title="delete this file" />
                    </td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr>
                <th class="footer" scope="col">File Name</th>
                <th class="footer" scope="col">Manage</th>
            </tr>        
        </tfoot>
    </table>

    @Html.PageLinks(Model.PagingInfo, x => Url.Action("ManageUploads", new { page = x }))
    @Html.HiddenFor(model => Model.OneTimeCode)

    <br /><br />
    <div id="upload-new">
        <div class="cpHeader">
            <b>Upload a file</b>
        </div>
        <div class="cpContent">
            <div class="fileUpload">
                @using (Html.BeginForm("UploadFileWithRefresh", "Uploads", FormMethod.Post, new { Area = "Admin", enctype = "multipart/form-data" }))
                {
                    <div>
                        <input type="file" id="file" name="file" />
                    </div>
                    <br /><br />
                    <div>
                        <input type="submit" value="Upload Selected File" class="submitBtn" />
                    </div>
                }
            </div>
        </div>
    </div>
</div>
